//
//  ZBPopupHintView.m
//  YouHui
//
//  Created by  on 11-12-30.
//  Copyright (c) 2011年 netease. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
#import "ZBPopupHintView.h"

@implementation ZBPopupHintView

+(void)showGlobalHint:(NSString*)text {
    ZBPopupHintView *hintView =[[[ZBPopupHintView alloc] init] autorelease];
    [hintView setText:text];
    UIView *parentView = [UIApplication sharedApplication].keyWindow;
    [hintView showInView:parentView];
    [hintView closeAfterSeconds:3];
}

-(void) closeAfterSeconds:(NSUInteger) seconds{
	[self performSelector:@selector(destory) withObject:nil afterDelay:seconds];
}


-(void)setText:(NSString *)textString{
	hintLabel.text = textString;
}

-(void) showInView:(UIView *)superView{
	self.transform=CGAffineTransformMakeScale(0.01,0.01);
	[UIView beginAnimations:nil context:nil];
	[UIView setAnimationCurve:UIViewAnimationCurveLinear];
	[superView addSubview:self];
	[superView bringSubviewToFront:self];
	self.transform=CGAffineTransformMakeScale(1,1);
	[UIView commitAnimations];
    
}

-(void) destory{
	[self removeFromSuperview];
}

-(id)init {
    return [self initWithFrame:CGRectMake(85, 100, 150, 80)];
}

-(id)initWithFrame:(CGRect)frame{
    if ((self = [super initWithFrame:frame])) {
        self.backgroundColor = [UIColor blackColor];
		self.alpha = 0.7f;
		self.layer.cornerRadius = 3;
		
		hintLabel = [[UILabel alloc] initWithFrame:CGRectMake((self.bounds.size.width-100)/2,(self.bounds.size.height-20)/2,100, 20)];
		hintLabel.textAlignment = UITextAlignmentCenter;
		hintLabel.backgroundColor = [UIColor clearColor];
		hintLabel.font = [UIFont boldSystemFontOfSize:16.0f];
		hintLabel.textColor = [UIColor whiteColor];
		[self addSubview:hintLabel];
    }
    return self;
}

- (void)dealloc {
	[hintLabel release];
    [super dealloc];
}

@end
